<template>
   <el-table :data="data" stripe style="width: 100%">
    <el-table-column prop="username" label="姓名"/>
    <el-table-column prop="reason" label="理由"  />
    <el-table-column prop="start" label="开始时间">
        <template #default="scope">
        {{dayjs(scope.row.start).format('YY-MM-DD HH:mm:ss')}}
        </template>
    </el-table-column>
    <el-table-column prop="end" label="结束时间">
        <template #default="scope">
        {{dayjs(scope.row.end).format('YY-MM-DD HH:mm:ss')}}
        </template>
    </el-table-column>
    <el-table-column prop="type" label="状态">
        
         <template #default="scope">
         <span v-if="type==1">
            <el-button link type="warning" v-if="scope.row.type == 1">待审批</el-button>
            <el-button link type="success" v-if="scope.row.type == 2">已同意</el-button>
            <el-button link type="danger"  v-if="scope.row.type == 3">已拒绝</el-button>

        </span>
         <span v-if="type==2">
            <span v-if="scope.row.type == 1">
            <el-button link type="success" @click="updateType(scope.row,2)">同意</el-button>
             <el-button link type="danger" @click="refuse(scope.row,3)">拒绝</el-button>
              </span>
            <el-button link type="success" v-if="scope.row.type == 2">已同意</el-button>
             <el-button link type="danger"  v-if="scope.row.type == 3">已拒绝</el-button>
        </span>
       
      </template>
    </el-table-column>
  </el-table>
</template>

<script setup>
import dayjs from 'dayjs';
import { defineProps,defineEmits} from 'vue';
const props = defineProps(['data','type'])
let emit = defineEmits("updateType",'refuse')
console.log(props.info);
let refuse =(item ,type)=>{
    emit("refuse",{item,type})
}
let updateType =(item ,type)=>{
    emit("updateType",{item,type})
}
</script>

<style >


</style>